Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-9350 Wizard: Show form-level errors after failed submission on subsequent form interaction when current page has no errors #5922

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

blakekrammes
Copy link
Contributor

@blakekrammes blakekrammes commented Nov 22, 2024

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-9350

Description

What changed?

  • Updated setPage() to display form errors if the form has failed to submit. setPage() is called when a user clicks
    directly on a Wizard nav link/button, but onChange() is not (this bug was fixed for onChange() by FIO-9360).
  • Updated nextPage() to check for failed submission; if there has been, display all the form errors. This is necessary for when a user clicks the "next" button without having resolved the error for that page. It causes validation to trigger for the current page only and wipes the other form errors.
  • Updated get errors() a.k.a. this.errors to grab the form-level errors if the form previously failed to submit. While this.showErrors() displayed the errors correctly, while testing I discovered that the errors were wiped incorrectly from the Wizard instance in this scenario and this.errors fell back to only returning errors for the current page.

Why have you chosen this solution?

  • Same concept/logic as FIO-9360, but applied to a couple more places.
    Basically, we check if the form has previously submitted (indicating a failed submission). If it has, we show all the form
    errors on every page until they are resolved individually on each page, as opposed to only validating the current page.
    FIO-9360 did this onChange(), but not for setPage() and nextPage().

Breaking Changes / Backwards Compatibility

n/a

Dependencies

n/a

How has this PR been tested?

Automated and manual. I de-duped up one of commonly-used helper functions in the Wizard tests and made it a global helper at the top of the Wizard tests. I also updated the async syntax for a flaky test to aid in potential future debugging.

Checklist:

  • I have completed the above PR template
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • My changes include tests that prove my fix is effective (or that my feature works as intended)
  • New and existing unit/integration tests pass locally with my changes
  • Any dependent changes have corresponding PRs that are listed above

@blakekrammes blakekrammes changed the title FIO-9350 Wizard: Show form errors on pages w/o required fields FIO-9350 Wizard: Show form-level errors after failed submission on subsequent form interaction when current page has no errors Nov 25, 2024
…ssion

- Show all form errors on page without required fields after failed submission
- Show all form errors on page with required fields after failed submission and after interacting with the page
- While showErrors worked as expected (defined in Webform), this.errors (get errors()) in Wizard was not persisting all the form errors after a failed submission
- Consolidate most link navigation to one global helper fn
…bmit

- Show form-level errors after failed submission even when the current page has no errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant